class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-07-24",
      revision: "e9439759d73fffb91f8ce63bc234f9f0f5150a84"
  version "2021-07-24"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "0b0d082a838e855305825c20a495ecfda9bd03f61a3a80617a11d482e1e8e9d0"
    sha256 cellar: :any_skip_relocation, big_sur:       "4c0cd4c977d024da6ffa316754435213f8c6d2168548cf0df270e7118b3cada4"
    sha256 cellar: :any_skip_relocation, catalina:      "ce0b951ed7df45551e210c480d67567ef297209db81b532b9b125866cf7e6a30"
    sha256 cellar: :any_skip_relocation, mojave:        "83bbb528073177ebc5451b1c9e3f2e314ee6b86f3feb4d07951e4e3e4221429e"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "b4afca5931d37bf3e467cb2693324847a523b9d910156cae5de44cffcdc18b9e"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
